package com.opengate.base.exception;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author 曳戈泰尔
 * @version 1.0
 * @description 自定义异常
 * @date 2023/4/26 5:46 PM
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "自定义异常")
public class OpenGateException extends RuntimeException {

    @Schema(description = "描述", required = true)
    private String msg;

    @Schema(description = "错误对象", required = true)
    private Object errorObj;

    @Schema(description = "状态码", required = true)
    protected int code;

    public OpenGateException() {}

    public OpenGateException(String message) {
        super(message);
        this.code = 4;
        this.msg = message;
    }

    public OpenGateException(int code, String message) {
        super(message);
        this.code = code;
        this.msg = message;
    }

    public OpenGateException(int code, String message, Object errorObj) {
        super(message);
        this.code = code;
        this.msg = message;
        this.errorObj = errorObj;
    }

    public OpenGateException(String msg, Throwable e) {
        super(msg, e);
        this.msg = msg;
    }
}
